﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

namespace KD.DAS.Cliecnt
{
    public class Main
    {
        /// <summary>
        /// 本类的唯一实例
        /// </summary>
        private static Main OWNER = null;

        /// <summary>
        /// 
        /// </summary>
        private static string _strErrInfo = string.Empty, _strErrCode = string.Empty;

        /// <summary>
        /// 私有构造函数
        /// </summary>
        private Main()
        {
            DAS.Component.Data.DataHelper.DoInit();
        }

        /// <summary>
        /// 获取类的唯一实例
        /// </summary>
        /// <returns></returns>
        public static Main Instance
        {
            get
            {
                if (Main.OWNER == null)
                {
                    Main.OWNER = new Main();
                }
                return Main.OWNER;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="lpr"></param>
        /// <param name="flowid"></param>
        /// <param name="tlen"></param>
        /// <param name="twidth"></param>
        /// <param name="len"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="postion"></param>
        /// <param name="date"></param>
        /// <param name="mine"></param>
        /// <param name="material"></param>
        /// <param name="supplier"></param>
        /// <param name="transport"></param>
        /// <param name="machine"></param>
        /// <param name="pail"></param>
        /// <param name="poscount"></param>
        /// <param name="layout"></param>
        /// <param name="begintime"></param>
        /// <param name="endtime"></param>
        /// <param name="state"></param>
        /// <param name="weight"></param>
        /// <param name="rfid"></param>
        /// <param name="pos"></param>
        /// <param name="DasUser"></param>
        /// <param name="DasPassword"></param>
        /// <returns></returns>
        public RequestResult DoUploadSamplingInfo(string lpr, string flowid, decimal tlen, decimal twidth, decimal len, decimal width, decimal height, string postion
           , string date, string mine, string material, string supplier, string transport
            , string machine, int pail, int poscount, int layout, string begintime, string endtime, int state, decimal weight, string rfid, string pos, string imgbegin, string imgend
            , string DasUser, string DasPassword,string sparestr1="")
        {
            RequestResult model = new RequestResult();
            Titan.DAS.Msg.Common.ProcParam[] _parms = new Titan.DAS.Msg.Common.ProcParam[]{
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_LPR",Value = lpr,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=200},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_PRIMARYKEY",Value = flowid,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=200},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_TOTLE_LENGTH",Value =tlen,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_TOTLE_WIDTH",Value =twidth,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_LENGTH",Value =len,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_WIDTH",Value =width,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_HEIGHT",Value =height,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_POSTIONS",Value = postion,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=200},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_DATE",Value =date,Direction = ParameterDirection.Input,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_MINE",Value =mine,Direction = ParameterDirection.Input,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=128},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_MATERIEL",Value =material,Direction = ParameterDirection.Input,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=128},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_SUPPLIER",Value =supplier,Direction = ParameterDirection.Input,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=128},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_TRANSPORT",Value =transport,Direction = ParameterDirection.Input,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=128},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_MECHINE",Value = machine,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_PAIL",Value =pail,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_POSCOUNT",Value =poscount,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_LAYOUT",Value =layout,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_BEGINTIME",Value =begintime,Direction = ParameterDirection.Input,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_ENDTIME",Value =endtime,Direction = ParameterDirection.Input,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_STATE",Value =state,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_WEIGHT",Value =weight,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_RDIF",Value =rfid,Direction = ParameterDirection.Input,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=128},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_POS",Value =pos,Direction = ParameterDirection.Input,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=128},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_IMG_BEGIN",Value =imgbegin,Direction = ParameterDirection.Input,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.Clob)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_IMG_END",Value =imgend,Direction = ParameterDirection.Input,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.Clob)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_SPARESTR1",Value =sparestr1,Direction = ParameterDirection.Input,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=128}};

            KD.DAS.Component.Data.EntityExecProc _modelProc = KD.DAS.Component.Data.DataHelper.ExecProc(DasUser, DasPassword, "PCK_INTERFACE_WL.DO_SYNC_CAR_LOGISTICS", _parms);
            if (!_modelProc.RSuccess || _modelProc.RStatuCode != 1)
            {
                model.En_ErrCode = _modelProc.RStatuCode.ToString();
                model.En_ErrInfo = _modelProc.RStatuDesc;
            }
            else
                model.En_Success = true;
            return model;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="lpr"></param>
        /// <param name="flowid"></param>
        /// <param name="tlen"></param>
        /// <param name="twidth"></param>
        /// <param name="len"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="postion"></param>
        /// <param name="mine"></param>
        /// <param name="material"></param>
        /// <param name="supplier"></param>
        /// <param name="transport"></param>
        /// <param name="DasUser"></param>
        /// <param name="DasPassword"></param>
        /// <returns></returns>
        public RequestResult DoSaveDataLocal(string lpr, string flowid, decimal tlen, decimal twidth, decimal len, decimal width, decimal height, string postion, string mine, string material, string supplier, string transport, string DasUser, string DasPassword)
        {
            RequestResult model = new RequestResult();
            Titan.DAS.Msg.Common.ProcParam[] _parms = new Titan.DAS.Msg.Common.ProcParam[]{
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_LPR",Value = lpr,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=200},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_FLOWID",Value = flowid,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=200},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_TOTLE_LENGTH",Value =tlen,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_TOTLE_WIDTH",Value =twidth,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_LENGTH",Value =len,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_WIDTH",Value =width,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_HEIGHT",Value =height,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_POSTIONS",Value = postion,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=200},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_MINE",Value = mine,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=200},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_MATERIEL",Value = material,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=200},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_SUPPLIER",Value = supplier,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=200},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_TRANSPORT",Value = transport,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=200}};

            KD.DAS.Component.Data.EntityExecProc _modelProc = KD.DAS.Component.Data.DataHelper.ExecProc(DasUser, DasPassword, "PCK_INTERFACE_WL.DO_SYNC_CAR_LOGISTICS", _parms);
            if (!_modelProc.RSuccess || _modelProc.RStatuCode != 1)
            {
                model.En_ErrCode = _modelProc.RStatuCode.ToString();
                model.En_ErrInfo = _modelProc.RStatuDesc;
            }
            else
            {
                model.En_Success = string.IsNullOrEmpty(_strErrInfo);
            }
            return model;
        }

        /// <summary>
        /// 发送采样请求
        /// </summary>
        /// <param name="car"></param>
        /// <returns></returns>
        public SamplingInfo DoSendRequest(string car, string DasUser, string DasPassword)
        {
            SamplingInfo _modeResult = new SamplingInfo();
            Titan.DAS.Msg.Common.ProcParam[] _parms = new Titan.DAS.Msg.Common.ProcParam[]{
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_CARCODE",Value =car,Direction = ParameterDirection.Input,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_BATCHCODE",Value =null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_PRIMARYKEY",Value =null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_PROCESSID",Value =null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_TOTALLENGTH",Value =null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_TOTALWIDTH",Value =null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_LENGTH",Value =null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_WIDTH",Value =null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_HEIGHT",Value =null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_POSTIONS",Value =null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_MINE",Value =null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_MINENAME",Value =null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_MATERIAL",Value =null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_MATERIALNAME",Value =null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_SUPPLIER",Value =null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_SUPPLIERNAME",Value =null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_TRICUNIT",Value =null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_TRICUNITNAME",Value =null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_POINTCOUNT",Value =null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_LAYOUTTYPE",Value =null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_ERRCODE",Value =null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_ERRINFO",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32( Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=8000}};

            KD.DAS.Component.Data.EntityExecProc _modelProc = KD.DAS.Component.Data.DataHelper.ExecProc(DasUser, DasPassword, "PCK_CARSAMPLE.SEND_REQUEST", _parms);
            if (_modelProc.RSuccess)
            {
                string _errCode = _modelProc.RParams[20].Value == null ? string.Empty : _modelProc.RParams[20].Value.ToString();
                string _errInfo = _modelProc.RParams[21].Value == null ? string.Empty : _modelProc.RParams[21].Value.ToString();
                if ((string.IsNullOrEmpty(_errCode) && string.IsNullOrEmpty(_errInfo)) || (_errCode == "null" && _errInfo == "null"))
                {
                    _modeResult.En_Success = true;
                    _modeResult.En_Car = car;
                    _modeResult.En_Batch = _modelProc.RParams[1].Value == null ? string.Empty : _modelProc.RParams[1].Value.ToString();
                    _modeResult.En_PrimaryKey = _modelProc.RParams[2].Value == null ? string.Empty : _modelProc.RParams[2].Value.ToString();
                    _modeResult.En_ProcessId = _modelProc.RParams[3].Value == null ? string.Empty : _modelProc.RParams[3].Value.ToString();
                    _modeResult.En_TotleLength = Convert.ToDouble(_modelProc.RParams[4].Value == null ? "0" : _modelProc.RParams[4].Value.ToString());
                    _modeResult.En_TotleWidth = Convert.ToDouble(_modelProc.RParams[5].Value == null ? "0" : _modelProc.RParams[5].Value.ToString());
                    _modeResult.En_Length = Convert.ToDouble(_modelProc.RParams[6].Value == null ? "0" : _modelProc.RParams[6].Value.ToString());
                    _modeResult.En_Width = Convert.ToDouble(_modelProc.RParams[7].Value == null ? "0" : _modelProc.RParams[7].Value.ToString());
                    _modeResult.En_Height = Convert.ToDouble(_modelProc.RParams[8].Value == null ? "0" : _modelProc.RParams[8].Value.ToString());
                    _modeResult.En_Postions = _modelProc.RParams[9].Value == null ? string.Empty : _modelProc.RParams[9].Value.ToString();
                    _modeResult.En_Mine = _modelProc.RParams[10].Value == null ? string.Empty : _modelProc.RParams[10].Value.ToString();
                    _modeResult.En_MineName = _modelProc.RParams[11].Value == null ? string.Empty : _modelProc.RParams[11].Value.ToString();
                    _modeResult.En_Materiel = _modelProc.RParams[12].Value == null ? string.Empty : _modelProc.RParams[12].Value.ToString();
                    _modeResult.En_MaterielName = _modelProc.RParams[13].Value == null ? string.Empty : _modelProc.RParams[13].Value.ToString();
                    _modeResult.En_Supplier = _modelProc.RParams[14].Value == null ? string.Empty : _modelProc.RParams[14].Value.ToString();
                    _modeResult.En_SupplierName = _modelProc.RParams[15].Value == null ? string.Empty : _modelProc.RParams[15].Value.ToString();
                    _modeResult.En_Transport = _modelProc.RParams[16].Value == null ? string.Empty : _modelProc.RParams[16].Value.ToString();
                    _modeResult.En_TransportName = _modelProc.RParams[17].Value == null ? string.Empty : _modelProc.RParams[17].Value.ToString();
                    _modeResult.En_SamplingPosCount = Convert.ToInt32(_modelProc.RParams[18].Value == null ? "0" : _modelProc.RParams[18].Value.ToString());
                    _modeResult.En_SamplingLayout = Convert.ToInt32(_modelProc.RParams[19].Value == null ? "0" : _modelProc.RParams[19].Value.ToString());
                }
                else
                {
                    _modeResult.En_ErrCode = _errCode;
                    _modeResult.En_ErrInfo = _errInfo;
                }
            }
            else
            {
                _modeResult.En_ErrCode = _modelProc.RStatuCode.ToString();
                _modeResult.En_ErrInfo = "采样请求发送失败，请检查服务端是否正常响应?";
            }
            return _modeResult;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="matchine"></param>
        /// <param name="processid"></param>
        /// <param name="poscount"></param>
        /// <param name="samplingtype"></param>
        /// <param name="samplinglayout"></param>
        /// <param name="pail"></param>
        /// <param name="points"></param>
        /// <param name="samplingid"></param>
        /// <returns></returns>
        public RequestResult DoSubmitSamplingBegin(string matchine, string processid, int poscount, int samplingtype, int samplinglayout, int pail, string points, string DasUser, string DasPassword)
        {
            RequestResult model = new RequestResult();
            Titan.DAS.Msg.Common.ProcParam[] _parms = new Titan.DAS.Msg.Common.ProcParam[]{
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_MECHINE",Value = matchine,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=40},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_PROCESSID",Value = processid,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=400},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_POSCOUNT",Value = poscount,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_SAMPLETYPE",Value =samplingtype,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_LAYOUTTYPE",Value = samplinglayout,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_PAIL",Value =pail,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_SAMPLEPOINTS",Value = points,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=2000},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_SAMPLINGID",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=400},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_ERRCODE",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_ERRINFO",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=2000}};

            KD.DAS.Component.Data.EntityExecProc _modelProc = KD.DAS.Component.Data.DataHelper.ExecProc(DasUser, DasPassword, "PCK_CARSAMPLE.SUBMIT_SAMPLING_BEGIN", _parms);
            if (!_modelProc.RSuccess || _modelProc.RStatuCode != 1)
            {
                model.En_ErrCode = _modelProc.RStatuCode.ToString();
                model.En_ErrInfo = _modelProc.RStatuDesc;
            }
            else
            {
                _strErrCode = _modelProc.RParams[_modelProc.RParams.Length - 2].Value == null ? string.Empty : _modelProc.RParams[_modelProc.RParams.Length - 2].Value.ToString();
                _strErrInfo = _modelProc.RParams[_modelProc.RParams.Length - 1].Value == null ? string.Empty : _modelProc.RParams[_modelProc.RParams.Length - 1].Value.ToString();
                _strErrInfo = _strErrInfo.Replace("null", "").Trim();
                model.En_Value = _modelProc.RParams[_modelProc.RParams.Length - 3].Value == null ? string.Empty : _modelProc.RParams[_modelProc.RParams.Length - 3].Value.ToString();
                model.En_Success = string.IsNullOrEmpty(_strErrInfo);
            }
            return model;
        }

        /// <summary>
        /// 提交采样结束
        /// </summary>
        /// <param name="samplingid"></param>
        /// <returns></returns>
        public RequestResult DoSubmitSamplingEnd(string samplingid, string DasUser, string DasPassword)
        {
            RequestResult model = new RequestResult();
            Titan.DAS.Msg.Common.ProcParam[] _parms = new Titan.DAS.Msg.Common.ProcParam[] { new Titan.DAS.Msg.Common.ProcParam { Name = "P_SAMPLEINGID", Value = samplingid, Direction = ParameterDirection.Input, DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2) } };
            KD.DAS.Component.Data.EntityExecProc _modelProc = KD.DAS.Component.Data.DataHelper.ExecProc(DasUser, DasPassword, "PCK_CARSAMPLE.SUBMIT_SAMPLING_END", _parms);
            if (!_modelProc.RSuccess || _modelProc.RStatuCode != 1)
            {
                model.En_ErrCode = _modelProc.RStatuCode.ToString();
                model.En_ErrInfo = _modelProc.RStatuDesc;
            }
            else
                model.En_Success = true;
            return model;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="samplingid"></param>
        /// <param name="pail"></param>
        /// <param name="weight"></param>
        /// <param name="rfid"></param>
        /// <returns></returns>
        public RequestResult DoSubmitSamplingWeight(string samplingid, string pail, string weight, string rfid, string DasUser, string DasPassword)
        {
            RequestResult model = new RequestResult();
            Titan.DAS.Msg.Common.ProcParam[] _parms = new Titan.DAS.Msg.Common.ProcParam[]{
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_SAMPLEINGID",Value = samplingid,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_PAIL",Value = pail,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_WEIGHT",Value = weight,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_RIID",Value =rfid,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_ERRCODE",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                                               new Titan.DAS.Msg.Common.ProcParam{Name = "P_ERRINFO",Value = null,Direction = ParameterDirection.Output,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2),Size=2000}};
            KD.DAS.Component.Data.EntityExecProc _modelProc = KD.DAS.Component.Data.DataHelper.ExecProc(DasUser, DasPassword, "PCK_CARSAMPLE.SUBMIT_SAMPLING_WEIGHT", _parms);
            if (!_modelProc.RSuccess || _modelProc.RStatuCode != 1)
            {
                model.En_ErrCode = _modelProc.RStatuCode.ToString();
                model.En_ErrInfo = _modelProc.RStatuDesc;
            }
            else
            {
                _strErrCode = _modelProc.RParams[_modelProc.RParams.Length - 2].Value == null ? string.Empty : _modelProc.RParams[_modelProc.RParams.Length - 2].Value.ToString();
                _strErrInfo = _modelProc.RParams[_modelProc.RParams.Length - 1].Value == null ? string.Empty : _modelProc.RParams[_modelProc.RParams.Length - 1].Value.ToString();
                _strErrInfo = _strErrInfo.Replace("null", "").Trim();
                model.En_Success = string.IsNullOrEmpty(_strErrInfo);
            }
            return model;
        }

        /// <summary>
        /// 实时更新采样点信息
        /// </summary>
        /// <param name="samplingid"></param>
        /// <param name="index"></param>
        /// <param name="block"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="z"></param>
        /// <returns></returns>
        public RequestResult DoUpdateSamplingPoint(string samplingid, int index, int block, int x, int y, int z, string DasUser, string DasPassword)
        {
            RequestResult model = new RequestResult();
            Titan.DAS.Msg.Common.ProcParam[] _parms = new Titan.DAS.Msg.Common.ProcParam[] {
                new Titan.DAS.Msg.Common.ProcParam { Name = "P_SAMPLEINGID", Value = samplingid, Direction = ParameterDirection.Input, DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2) },
                new Titan.DAS.Msg.Common.ProcParam{Name = "P_INDEX",Value = index,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                new Titan.DAS.Msg.Common.ProcParam{Name = "P_BLOCK",Value = block,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                new Titan.DAS.Msg.Common.ProcParam{Name = "P_X",Value = x,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                new Titan.DAS.Msg.Common.ProcParam{Name = "P_Y",Value = y,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                new Titan.DAS.Msg.Common.ProcParam{Name = "P_Z",Value = z,Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)}};
            KD.DAS.Component.Data.EntityExecProc _modelProc = KD.DAS.Component.Data.DataHelper.ExecProc(DasUser, DasPassword, "PCK_CARSAMPLE.UPDATE_SAMPLING_POINT", _parms);
            if (!_modelProc.RSuccess || _modelProc.RStatuCode != 1)
            {
                model.En_ErrCode = _modelProc.RStatuCode.ToString();
                model.En_ErrInfo = _modelProc.RStatuDesc;
            }
            else
                model.En_Success = true;
            return model;
        }

        /// <summary>
        /// 提交采样图片
        /// </summary>
        /// <param name="samplingid"></param>
        /// <param name="isbegin"></param>
        /// <param name="iamge"></param>
        /// <returns></returns>
        public RequestResult DoSubmitSamplingImage(string samplingid, bool isbegin, string iamge, string DasUser, string DasPassword)
        {
            RequestResult model = new RequestResult();
            Titan.DAS.Msg.Common.ProcParam[] _parms = new Titan.DAS.Msg.Common.ProcParam[] {
                new Titan.DAS.Msg.Common.ProcParam { Name = "P_SAMPLEINGID", Value = samplingid, Direction = ParameterDirection.Input, DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2) },
                new Titan.DAS.Msg.Common.ProcParam{ Name = "P_IMAGETYPE",Value = Convert.ToInt32(isbegin),Direction = ParameterDirection.Input,DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.Decimal)},
                new Titan.DAS.Msg.Common.ProcParam { Name = "P_SAMPLEIMAGE", Value = samplingid, Direction = ParameterDirection.Input, DbType = Convert.ToInt32(Titan.DAS.Client.Data.ODB_Type.NVarchar2) }
            };
            KD.DAS.Component.Data.EntityExecProc _modelProc = KD.DAS.Component.Data.DataHelper.ExecProc(DasUser, DasPassword, "PCK_CARSAMPLE.SUBMIT_IMAGE", _parms);
            if (!_modelProc.RSuccess || _modelProc.RStatuCode != 1)
            {
                model.En_ErrCode = _modelProc.RStatuCode.ToString();
                model.En_ErrInfo = _modelProc.RStatuDesc;
            }
            else
                model.En_Success = true;
            return model;
        }

    }
}
